home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ASM-K.ZIP / KILLEDDI.ASM < prev    next >
Assembly Source File  |  1989-06-24  |  10KB  |  654 lines

  1.  
  2. memS    equ 1           ;model small  convertable to COM model
  3. ;****************    RUNTIME LIBRARY OF KILLDIANA.COM     **************
  4. include lcmac.mac
  5. calln    macro    name
  6.     call near ptr name
  7.     endm
  8. callp    macro    name
  9.     lea    dx,name
  10.     calln    print
  11.     endm
  12. callz    macro    name
  13.     push    si
  14.     lea    si,name
  15.     calln    printz
  16.     pop    si
  17.     endm
  18.  
  19. dtas    struc
  20.     resv    db    21 dup(?)
  21.     atr    db    ?
  22.     hour    dw    ?
  23.     min    dw    ?
  24.     lfil    dw    ?
  25.     hfil    dw    ?
  26.     sname    db    14 dup(?)
  27. dtas    ends
  28.  
  29. dgroup    group data,udata,xstack
  30.     assume ds:data
  31.  
  32. pgroup    group prog,tail
  33. prog    segment byte public 'prog'
  34.     assume cs:prog
  35.  
  36.     org    100h            ;FOR MODEL COM
  37.  
  38. start    label     far
  39.     cli
  40.     mov    ax,offset pgroup:xtail    ;get end of code group
  41.     add    ax,16            ;calculate segment address of ds
  42.     mov    cl,4            ;calculate segment address of ds
  43.     shr    ax,cl            ;calculate segment address of ds
  44.     mov    bx,cs            ;calculate segment address of ds
  45.     add    ax,bx            ;calculate segment address of ds
  46.     mov    ds,ax            ;set ds to dgroup
  47.     mov    es,ax            ;set es to dgroup
  48.     mov    ss,ax            ;set ss to dgroup
  49.     mov    ds:_ss,ax        ;save stack segment for (do,for,while)
  50.     mov    sp,offset dgroup:sbase + 512    ;range of stack = 512 bytes
  51.     mov    ds:_top,sp        ;save stack pointer for (do,for,while)
  52.     mov    bx,offset dgroup:sbase    ;get  stack segment for (do,for,while)
  53.     mov    ds:_base,bx        ;save stack segment for (do,for,while)
  54.     sti
  55.     mov    ah,30h            ;get dos version number
  56.     int    21h
  57.     mov    ds:_dos,ax        ;save dos version for (do,for,while)
  58.     callp    copyr
  59.     callp    tryrem
  60.     calln    remove
  61.     push    cs
  62.     pop    es
  63.  
  64.     mov    di,81h
  65. getf:
  66.     mov    cx,80
  67.     cld
  68.     mov    al,0dh
  69. repne    scasb
  70.     jne    quiter
  71.     dec    di
  72.     cmp    di,81h
  73.     je    quiter
  74.     mov    si,di
  75.     mov    cx,di
  76.     mov    cs:byte ptr[di],0
  77. srcc:
  78.     dec    si
  79.     mov    al,cs:[si]
  80.     cmp    al,'\'
  81.     je    fndd
  82.     cmp    al,':'
  83.     je    fndd
  84.     cmp    si,82h
  85.     jae    srcc
  86.     dec    si
  87. fndd:
  88.     sub    cx,si
  89.     jcxz    quiter
  90.     lea    di,fname
  91.     inc    si
  92. cpcp:    mov    al,cs:[si]
  93.     cmp    al,' '
  94.     jbe    incsi
  95.     mov    [di],al
  96.     inc    di
  97. incsi:
  98.     inc    si
  99.     loop    cpcp
  100.     callp    weak
  101.     lea    dx,root
  102.     mov    ah,3bh        ;chdir to root
  103.     int    21h        ;chdir to root
  104.     calln    findir
  105. quiter:
  106.     mov    ah,4ch
  107.     int    21h        ;exit to DOS
  108.  
  109. print    proc    near
  110.     mov    ah,9
  111.     int    21h
  112.     ret
  113. print    endp
  114.  
  115. comwrk    proc    near
  116.     calln    first
  117.     jc    toret
  118.     calln    workcom
  119. ffnext:
  120.     calln    fnext
  121.     jc    toret
  122.     calln    workcom
  123.     .br    ffnext
  124. toret:
  125.     ret
  126. comwrk    endp
  127. fnext    proc    near
  128.     lea    dx,mydta
  129.     mov    ah,1ah
  130.     int    21h
  131.     mov    ah,4fh        ;findnext
  132.     int    21h
  133.     jc    ercc
  134.     jnc    foundf
  135. fnext    endp
  136. first    proc    near
  137.     lea    dx,mydta
  138.     mov    ah,1ah
  139.     int    21h
  140.     lea    dx,fname
  141.     mov    cx,27h        ;search all types of files
  142.     mov    ah,4eh        ;findfirst
  143.     int    21h
  144.     jnc    foundf
  145. ;    callp    notfnd
  146. ercc:    stc
  147.     ret
  148. foundf:
  149.     calln    konka
  150.     clc
  151.     ret
  152. first    endp
  153. konka    proc    near
  154.     mov    ah,2fh
  155.     int    21h        ;get dta  in es:bx
  156.     add    bx,26
  157.     mov    ax,es:[bx]
  158.     mov    llfil,ax    ;save lowlengh
  159.     inc    bx
  160.     inc    bx
  161.     mov    ax,es:[bx]
  162.     mov    lhfil,ax    ;save highlengh
  163.     inc    bx
  164.     inc    bx        ;pointed to fname
  165.     lea    si,ffname
  166. copyf:    mov    al,es:[bx]
  167.     mov    [si],al
  168.     inc    si
  169.     inc    bx
  170.     or    al,al
  171.     jne    copyf
  172.     ret
  173. konka    endp
  174.  
  175.  
  176.  
  177. remove    proc    near
  178.     push    ds
  179.     clr    ax
  180.     mov    ds,ax
  181.     les    bx,ds:[84h]       ;21h vector
  182.     mov    ax,cs
  183.     mov    dx,es
  184.     cmp    dx,ax
  185.     jc    nodia
  186.     cmp    bx,2eeh
  187.     jne    nodia
  188.  
  189.     mov    ax,es:[74fh]
  190.     mov    ds:[84h],ax       ;restore 21h
  191.     mov    ax,es:[751h]
  192.     mov    ds:[86h],ax
  193.  
  194.     mov    ax,es:[74bh]
  195.     mov    ds:[9ch],ax       ;restore 27h
  196.     mov    ax,es:[74dh]
  197.     mov    ds:[9eh],ax
  198.     mov    ax,es
  199.     mov    bx,ax
  200.     dec    ax
  201.     mov    es,ax
  202.     mov    es:byte ptr[0],5ah
  203.     mov    es:word ptr[1],0
  204.     pop    ds
  205.     callp    diakt
  206.     ret
  207. nodia:
  208.     pop    ds
  209.     callp    dinakt
  210.     ret
  211. remove    endp
  212.  
  213. workcom proc    near
  214.     lea    dx,ffname
  215.     mov    ax,4300h    ;get attrib
  216.     int    21h
  217.     jnc    kopa
  218.     jmp    retga
  219. kopa:
  220.     mov    al,cl
  221.     and    al,0feh
  222.     cmp    al,cl
  223.     je    nochatr
  224.  
  225.     mov    attr,cx
  226.     mov    ax,4301h    ;set attrib
  227.     clr    cx        ;to normal
  228.     int    21h
  229.     .br    nochh
  230. nochatr:
  231.     mov    attr,0
  232. nochh:
  233.     mov    ax,3d02h    ;open file R/W
  234.     int    21h
  235.     jnc    kop1
  236.     jmp    resatr
  237. kop1:    mov    bx,ax
  238.     calln    gettm
  239.     mov    cx,18h
  240.     lea    dx,bufer
  241.     mov    ah,3fh        ;read first 3 bytes
  242.     int    21h
  243.     jc    closs2
  244.     mov    di,dx
  245.     mov    ax,ds:[di]
  246.     cmp    ax,5a4dh
  247.     jne    commfil
  248.     push    bx
  249.     calln    exework
  250.     pop    bx
  251.     jc    chek2
  252.     jmp    closs
  253.  
  254. commfil:
  255.     mov    al,ds:[di]
  256.     cmp    al,0e9h
  257.     je    mak111
  258.     jmp    closs
  259. mak111: mov    si,ds:[di+1]    ;relative offset
  260.     add    si,3
  261.     mov    di,si
  262.     sub    si,68h
  263.     mov    len,si
  264.  
  265.     clr    cx
  266.     mov    dx,di
  267.     mov    ax,4200h
  268.     int    21h        ;seek to found e80000
  269. closs2: jc    clos21
  270.  
  271.     lea    dx,bufer
  272.     add    dx,18h+3
  273.     mov    cx,7        ;read 7 bytes
  274.     mov    ah,3fh
  275.     int    21h        ;read
  276. clos21: jnc    chek1
  277. chek2:    jmp    closs
  278. chek1:
  279.     mov    di,dx
  280.     cmp    ds:byte ptr[di],0e8h
  281.     jne    chek2
  282.     cmp    ds:word ptr[di+1],0
  283.     jne    chek2
  284.     cmp    ds:word ptr[di+4],0ee81h
  285.     jne    chek2
  286.     cmp    ds:word ptr[di+6],6bh
  287.     jne    chek2
  288.  
  289.     clr    cx
  290.     mov    dx,si
  291.     add    dx,705h
  292.     mov    ax,4200h
  293.     int    21h        ;seek to found org 3bytes
  294.     jc    closs
  295.     lea    dx,bufer
  296.     add    dx,18h
  297.     mov    cx,3        ;read 3 bytes
  298.     mov    ah,3fh
  299.     int    21h        ;read
  300.     jc    closs
  301.     lea    si,bufer
  302. restor3:
  303.     mov    al,[si+18h]
  304.     mov    [si],al
  305.     inc    si
  306.     loop    restor3
  307.     clr    cx
  308.     clr    dx
  309.     mov    ax,4200h    ;seek to begin
  310.     int    21h
  311.     jc    closs
  312.  
  313.     mov    cx,18h
  314.     lea    dx,bufer
  315.     mov    ah,40h        ;write
  316.     int    21h
  317.     jc    closs
  318.  
  319.     clr    cx
  320.     mov    dx,len
  321.     mov    ax,4200h    ;seek to end of real data
  322.     int    21h
  323.     jc    resatr
  324. exelen:
  325.     clr    cx
  326.     mov    ah,40h        ;truncate file
  327.     int    21h
  328.     push    bx
  329.     callp    file
  330.     callz    ffname
  331.     callp    isok
  332.  
  333.     pop    bx
  334. closs:
  335.     calln    settm
  336.     mov    ah,3eh
  337.     int    21h        ;close file
  338.  
  339. resatr:
  340.     mov    cx,attr     ;to old attributes
  341.     or    cx,cx
  342.     je    retga
  343.     lea    dx,ffname
  344.     mov    ax,4301h    ;set attrib
  345.     int    21h
  346. retga:
  347.     ret
  348. workcom endp
  349. printz    proc    near
  350. eter:    mov    ah,2
  351.     lodsb
  352.     or    al,al
  353.     je    caret
  354.     mov    dl,al
  355.     int    21h
  356.     .br    eter
  357. caret:
  358.     ret
  359. printz    endp
  360.  
  361. gettm    proc    near
  362.     mov    ax,5700h
  363.     int    21h
  364.     jc    qget
  365.     mov    atcx,cx
  366.     mov    atdx,dx
  367. qget:
  368.     ret
  369. gettm    endp
  370.  
  371. settm    proc    near
  372.     mov    ax,5701h
  373.     mov    cx,atcx
  374.     mov    dx,atdx
  375.     or    cx,cx
  376.     je    qset
  377.     or    dx,dx
  378.     je    qset
  379.     int    21h
  380. qset:
  381.     ret
  382. settm    endp
  383. exework proc    near
  384.     mov    ax,[di+16h]      ;get main lenght in pargarphs
  385.     mov    cx,16
  386.     mul    cx
  387.     push    bx
  388.     mov    bx,[di+8]
  389.     mov    cl,4
  390.     shl    bx,cl
  391.     add    ax,[di+14h]      ;get IP
  392.     adc    dx,0
  393.     add    ax,bx
  394.     adc    dx,0
  395.     pop    bx
  396.     mov    exhlen,dx
  397.     mov    exllen,ax
  398.     mov    cx,dx
  399.     mov    dx,ax
  400.     mov    ax,4200h
  401.     int    21h        ;seek to begin Diana code
  402.  
  403.     lea    dx,bufer
  404.     add    dx,18h+3
  405.     mov    cx,7        ;read 7 bytes
  406.     mov    ah,3fh
  407.     int    21h        ;read
  408.     jc    echek2
  409.     mov    di,dx
  410.     cmp    ds:byte ptr[di],0e8h
  411.     jne    echek2
  412.     cmp    ds:word ptr[di+1],0
  413.     jne    echek2
  414.     cmp    ds:word ptr[di+4],0ee81h
  415.     jne    echek2
  416.     cmp    ds:word ptr[di+6],6bh
  417.     je    exgoin
  418. echek2:
  419.     stc
  420.     ret
  421. exgoin:
  422.     sub    exllen,68h
  423.     sbb    exhlen,0    ;contains lenght of file
  424.  
  425.     mov    dx,exllen
  426.     mov    cx,exhlen
  427.     add    dx,707h
  428.     adc    cx,0
  429.     mov    ax,4200h
  430.     int    21h        ;seek to old vectors
  431.     lea    dx,bufer
  432.     add    dx,26h
  433.     mov    cx,1
  434.     mov    ah,3fh
  435.     int    21h        ;read    old cs:ip,  ss:sp
  436.     jc    echek2
  437.  
  438.     mov    dx,exllen
  439.     mov    cx,exhlen
  440.     add    dx,6fdh
  441.     adc    cx,0
  442.     mov    ax,4200h
  443.     int    21h        ;seek to old vectors
  444.     lea    dx,bufer
  445.     add    dx,18h
  446.     mov    cx,8
  447.     mov    ah,3fh
  448.     int    21h        ;read    old cs:ip,  ss:sp
  449.     jc    echek2
  450.  
  451.     mov    ax,llfil
  452.     mov    dx,lhfil
  453.     sub    ax,exllen
  454.     sbb    dx,exhlen
  455.     mov    lhfil,dx
  456.     mov    llfil,ax
  457.     lea    di,bufer
  458.     mov    ax,[di+4]
  459.     mov    cx,512
  460.     mul    cx
  461.     add    ax,[di+2]
  462.     adc    dx,0
  463.     sub    ax,llfil
  464.     sbb    dx,lhfil
  465.     div    cx
  466.     mov    cx,dx
  467.     mov    dl,[di+26h]
  468.     sub    cx,dx
  469.     mov    rema,cx
  470.     mov    [di+2],dx    ;store remainder of lenght
  471.     mov    [di+4],ax    ;store /512 lenght
  472.  
  473.     mov    ax,[di+18h]    ;get ip
  474.     mov    [di+14h],ax    ;store
  475.     mov    ax,[di+1ah]    ;get cs:
  476.     mov    [di+16h],ax    ;store
  477.  
  478.     mov    ax,[di+1ch]    ;get sp
  479.     mov    [di+10h],ax    ;store
  480.     mov    ax,[di+1eh]    ;get ss:
  481.     mov    [di+0eh],ax    ;store
  482.  
  483.     clr    cx
  484.     clr    dx
  485.     mov    ax,4200h
  486.     int    21h        ;seek to prefix
  487.     mov    cx,18h        ;to write new prefix
  488.     lea    dx,bufer
  489.     mov    ah,40h
  490.     int    21h        ;write 18h bytes prefix
  491.     mov    cx,exhlen
  492.     mov    dx,exllen
  493.     sub    dx,rema
  494.     sbb    cx,0
  495.     mov    ax,4200h
  496.     int    21h        ;seek end of file
  497.     jmp    exelen
  498. exework endp
  499.  
  500. findir    proc    near
  501.     ;    get dta
  502.     mov    ah,2fh
  503.     int    21h
  504.     mov    word ptr olddta[0],bx
  505.     mov    word ptr olddta[2],es
  506.     ;*****
  507.     lea    dx,mydta
  508.     mov    ah,1ah
  509.     int    21h
  510.     calln    comwrk
  511.     mov    word ptr fflag,0
  512.     calln    basewr
  513.  
  514.     ; restore dta
  515.     push    ds
  516.     lds    dx,olddta
  517.     mov    ah,1ah
  518.     int    21h
  519.     pop    ds
  520.     ret
  521. findir    endp
  522.  
  523. basewr    proc    near
  524.     cmp    word ptr fflag,0
  525.     jne    nnextt
  526.     calln    fdir
  527.     jc    baret
  528.     jnc    checkk
  529. nnextt:
  530.     calln    ndir
  531.     jc    baret
  532. checkk:
  533.     mov    bx,odta
  534.     test    ds:byte ptr[bx + dtas.atr],10h
  535.     je    nnextt
  536.     cmp    byte ptr dtas.sname[bx],'.'
  537.     je    nnextt
  538.     mov    ah,3bh        ;chdir
  539.     mov    dx,offset dtas.sname
  540.     add    dx,bx
  541.     int    21h        ;chdir
  542.     calln    pdir
  543.     calln    comwrk
  544.     mov    fflag,0
  545.     inc    coudir
  546.     calln    basewr
  547. bare:
  548.     pushf
  549.     lea    dx,point
  550.     mov    ah,3bh        ;chdir up
  551.     int    21h        ;chdir up
  552.     dec    coudir
  553.     jns    nosig
  554.     mov    coudir,0
  555. nosig:
  556.     mov    fflag,1
  557.     popf
  558.     .br    nnextt
  559.  
  560. baret:
  561.     ret
  562. basewr    endp
  563. ndir    proc    near
  564.     calln    stdta
  565.     mov    ah,4fh
  566.     int    21h
  567.     ret
  568. ndir    endp
  569. fdir    proc    near
  570.     calln    stdta
  571.     lea    dx,aster
  572.     mov    cx,37h
  573.     mov    ah,4eh
  574.     int    21h
  575.     ret
  576. fdir    endp
  577. stdta    proc    near
  578.     mov    ax,44
  579.     mul    word ptr coudir
  580.     add    ax,offset dtatab
  581.     mov    odta,ax
  582.     mov    dx,ax
  583.     mov    ah,1ah
  584.     int    21h
  585.     ret
  586. stdta    endp
  587. pdir    proc    near
  588.     push    si
  589.     lea    si,curdir
  590.     clr    dl
  591.     mov    ah,47h
  592.     int    21h
  593.     lea    si,curdir
  594.     calln    printz
  595.     callp    carret
  596.     pop    si
  597.     ret
  598. pdir    endp
  599. prog    ends
  600.  
  601. tail    segment word 'prog'     ;help segment to allocate end of code
  602. xtail    dw    -1        ;and set the data segment
  603. tail    ends
  604.  
  605. data    segment para public 'data'     ;data segment
  606.  
  607.  
  608. fname    db    10h dup(0)
  609. ffname    db    10h dup(0)
  610. mydta    db    48  dup(?)
  611. bufer    db    28h dup(0)
  612. dtatab    dtas    12  dup(<>)
  613. curdir    db    64 dup(?)
  614. _ss    dw    ?    ;Lattice variables
  615. _base    dw    ?    ;Lattice variables
  616. _dos    dw    ?    ;Lattice variables
  617. _top    dw    ?    ;Lattice variables
  618. odta    dw    0
  619. olddta    dd    0
  620. nepar    dw    0
  621. fhand    dw    0
  622. exhlen    dw    0
  623. exllen    dw    0
  624. llfil    dw    0
  625. lhfil    dw    0
  626. len    dw    0
  627. attr    dw    0
  628. atcx    dw    0
  629. atdx    dw    0
  630. rema    dw    0
  631. coudir    dw    0
  632. fflag    dw    0
  633. ;notfnd  db     'File not found',13,10,'$'
  634. copyr    db    'Dianakiller program V1.1  (C)Copyright Deny_Soft 1989',13,10,'$'
  635. tryrem    db    'Searching Diana in memory..',13,10,'$'
  636. diakt    db    'Diana found',7,' and removed extra',13,10,'$'
  637. dinakt    db    "Diana isn't active",13,10,"$"
  638. weak    db    'Searching for weak  files...',13,10,'$'
  639. file    db    'File $'
  640. isok    db    9,9,' ... restored',13,10,'$'
  641. carret    db    13,10,'$'
  642. aster    db    '*.*',0
  643. point    db    '..',0
  644. root    db    '\',0
  645.  
  646. data    ends
  647.     .pub    <_ss,_base,_dos,_top>    ;make external
  648. udata    segment public 'data'
  649. udata    ends
  650. xstack    segment 'data'
  651. sbase    dw    512 dup (?)
  652. xstack    ends
  653.     end    start
  654.